﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Zocono.Infrastructure.Common;
using Zocono.WCS.Application.AppLogManage;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WCS.Infrastructure.ApllicationDto;
using Zocono.WCS.Infrastructure.ApllicationDto.DtoWcsManage;

namespace Zocono.WCS.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LogController : ControllerBase
    {
        private readonly LogApp _LogApp;
        public LogController(LogApp logApp)
        {
            _LogApp= logApp;
        }
        [HttpPost]
        public async Task<HeaderResult< List<OperateLogInfoDto>>> GetOperateLogInfoAsync(OperateLogInfoDto operateLogInfoDto)
        {
            HeaderResult<List<OperateLogInfoDto>> headerResult=new HeaderResult<List<OperateLogInfoDto>>();
            //var result= await _LogApp.GetOperateLogInfoAsync(operateLogInfoDto);
            try
            {
                PageDto<OperateLogInfoDto> pageDto = await _LogApp.GetOperateLogInfoAsync(operateLogInfoDto);
                headerResult.IsSucceed = true;
                headerResult.Result = pageDto.Result;
                headerResult.Total = pageDto.Total;
                headerResult.Message = "查询成功";
            }
            catch (Exception ex)
            {
                headerResult.IsSucceed = false;
                headerResult.Message = ex.ToString();
            }
            return headerResult;
        }

        [HttpPost]
        public async Task<bool> CreateOperateLogInfoAsync(OperateLogInfoDto operateLogInfoDto)
        {
            return await _LogApp.CreateOperateLogInfoAsync(operateLogInfoDto);
        }

    }
}
